package utils

import (
	"chat/log"
	"fmt"

	"github.com/gin-gonic/gin"
	uuid "github.com/satori/go.uuid"
)

func Error(err error) {
	if err != nil {
		log.Error(fmt.Sprintf("%v", err))
	}
}

// 获取当前服务器地址
func GetBaseURL(c *gin.Context) string {
	req := c.Request
	if req.URL.IsAbs() {
		return req.URL.Scheme + "://" + req.URL.Host
	}
	return req.URL.Scheme + "://" + req.Host
}

func GetUUID() string {
	return uuid.NewV4().String()
}
